﻿Public Class FrmMain

    Private Sub SuperTabControlPanel1_SizeChanged(sender As Object, e As EventArgs) Handles SuperTabControlPanel1.SizeChanged
        FP1.Left = (GP1.Width - FP1.Width) / 2
        FP2.Left = (GP2.Width - FP2.Width) / 2
        FP3.Left = (GP3.Width - FP3.Width) / 2
        FP4.Left = (GP4.Width - FP4.Width) / 2
        FP5.Left = (GP5.Width - FP5.Width) / 2
    End Sub

    Private Sub FrmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
        Binfo.IsClose = True
        Application.Exit()
    End Sub

    Private Sub ButtonX1_Click(sender As Object, e As EventArgs) Handles ButtonX1.Click
        If SControl._User_CheckAuth(UInfo.FSession, "BILL", "FPBILLNEW", "") = False Then
            MsgBox("没有权限!")
            Return
        End If
        Dim f1 As New FrmPropertyBill With {.FOpenType = "NewBill"}
        f1.ShowDialog()
    End Sub

    Private Sub ButtonX3_Click(sender As Object, e As EventArgs) Handles ButtonX3.Click
        If SControl._User_CheckAuth(UInfo.FSession, "BILL", "FCBILLNEW", "") = False Then
            MsgBox("没有权限!")
            Return
        End If
        Dim f1 As New FrmCashBill With {.FOpenType = "NewBill"}
        f1.ShowDialog()
    End Sub

    Private Sub ButtonX6_Click(sender As Object, e As EventArgs) Handles ButtonX6.Click
        If SControl._User_CheckAuth(UInfo.FSession, "BILL", "FUBILLNEW", "") = False Then
            MsgBox("没有权限!")
            Return
        End If
        Dim f1 As New FrmProductBill With {.FOpenType = "NewBill"}
        f1.ShowDialog()
    End Sub

    Private Sub ButtonX8_Click(sender As Object, e As EventArgs) Handles ButtonX8.Click
        If SControl._User_CheckAuth(UInfo.FSession, "BILL", "FWBILLNEW", "") = False Then
            MsgBox("没有权限!")
            Return
        End If
        Dim f1 As New FrmWaterBill With {.FOpenType = "NewBill"}
        f1.ShowDialog()
    End Sub

    Private Sub ButtonItem1_Click(sender As Object, e As EventArgs) Handles ButtonItem1.Click
        Dim f1 As New FrmPropertyQueryBill
        f1.ShowDialog()
        f1 = Nothing
    End Sub

    Private Sub ButtonItem2_Click(sender As Object, e As EventArgs) Handles ButtonItem2.Click
        Dim f1 As New FrmCashQueryBill
        f1.ShowDialog()
        f1 = Nothing
    End Sub

    Private Sub ButtonItem3_Click(sender As Object, e As EventArgs) Handles ButtonItem3.Click
        Dim f1 As New FrmProductQuery
        f1.ShowDialog()
        f1 = Nothing
    End Sub

    Private Sub ButtonItem4_Click(sender As Object, e As EventArgs) Handles ButtonItem4.Click
        Dim f1 As New FrmWaterQuery
        f1.ShowDialog()
        f1 = Nothing
    End Sub

    Private Sub ButtonX9_Click(sender As Object, e As EventArgs) Handles ButtonX9.Click
        Dim f1 As New FrmUserManage
        f1.ShowDialog()
        f1 = Nothing
    End Sub

    Private Sub ButtonX10_Click(sender As Object, e As EventArgs) Handles ButtonX10.Click
        Dim f1 As New FrmAuthManage
        f1.ShowDialog()
        f1 = Nothing
    End Sub

    Private Sub FrmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If IO.File.Exists(Application.StartupPath & "\stdn.h") Then
            IO.File.Delete(Application.StartupPath & "\stdn.h")
            FLogs.ShowDialog()
        End If
        Timer1.Interval = 60000
        Timer1.Enabled = True
        Timer1.Start()
        '--状态栏
        ToolStripStatusLabel2.Text = UInfo.FName
        SControl._BASE_Org_GetOrgInfo(UInfo.FSession, UInfo.FOrgid, ToolStripStatusLabel4.Text, "")
        ToolStripStatusLabel6.Text = UInfo.FRName
        ComboBox1.SelectedIndex = 0
        DateTimePicker1.Value = Now
        DateTimePicker2.Value = Now
    End Sub
    Private Sub Breath()
        Try
            If SControl._BASE_Breath(UInfo, "") = False Then
                If MsgBox("您已掉线或在别处登录,是否关闭程序重新登录?", MsgBoxStyle.YesNo, "在线检测") = MsgBoxResult.No Then
                    Return
                Else
                    Application.Restart()
                    Return
                End If
            End If
        Catch ex As Exception
            Return
        End Try
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Dim th1 As New Threading.Thread(AddressOf Breath)
        th1.Start()
        th1 = Nothing
    End Sub

    Private Sub ButtonItem12_Click(sender As Object, e As EventArgs) Handles ButtonItem12.Click
        Dim f1 As New FrmMyPass
        f1.ShowDialog()
        f1 = Nothing
    End Sub

    Private Sub ButtonItem13_Click(sender As Object, e As EventArgs) Handles ButtonItem13.Click
        Dim f1 As New FLogs
        f1.ShowDialog()
        f1 = Nothing
    End Sub

    Private Sub ButtonX11_Click(sender As Object, e As EventArgs) Handles ButtonX11.Click
        Dim f1 As New FrmUserPair
        f1.ShowDialog()
        f1 = Nothing
    End Sub

    Private Sub ButtonX12_Click(sender As Object, e As EventArgs) Handles ButtonX12.Click
        If SControl._User_CheckAuth(UInfo.FSession, "SYS", "FMANAGEORG", "") = False Then
            MsgBox("没有权限!")
            Return
        End If
        Dim f1 As New FrmUserOrg
        f1.ShowDialog()
        f1 = Nothing
    End Sub

    Private Sub ButtonItem10_Click(sender As Object, e As EventArgs) Handles ButtonItem10.Click
        Application.Restart()
    End Sub

    Private Sub ButtonItem11_Click(sender As Object, e As EventArgs) Handles ButtonItem11.Click
        Application.Exit()
    End Sub

    Private Sub ButtonX14_Click(sender As Object, e As EventArgs) Handles ButtonX14.Click
        Dim f1 As New FrmPropDownBill With {.FOpenType = "New"}
        f1.ShowDialog()
        f1 = Nothing
    End Sub

    Private Sub ButtonItem14_Click(sender As Object, e As EventArgs) Handles ButtonItem14.Click
        Dim f1 As New FrmPropDownQuery
        f1.ShowDialog()
        f1 = Nothing
    End Sub

   
    Private Sub ButtonX16_Click(sender As Object, e As EventArgs) Handles ButtonX16.Click
        FControl.ExpertToXls(DataGridView1)
    End Sub

    Private Sub ButtonX15_Click(sender As Object, e As EventArgs) Handles ButtonX15.Click
        Try
            Dim ErrString As String = String.Empty
            Dim TmpArr As Byte() = Nothing
            Dim Ds As DataSet = Nothing
            DataGridView1.DataSource = Nothing
            If SControl._ELEC_GetBillList(UInfo.FSession, ComboBox1.Text, DateTimePicker1.Value.Date, DateTimePicker2.Value.Date, TmpArr, ErrString) = False Then
                MsgBox(ErrString)
                Return
            End If
            If FControl.DsRestore(Ds, TmpArr) = False Then
                MsgBox("无法解析返回数据!")
                Return
            End If
            DataGridView1.DataSource = Ds.Tables(0).DefaultView
        Catch ex As Exception

        End Try
    End Sub
End Class